Public Class Currency
#Region "Fields and Properties"
    Public Name As String
    Public Symbol As ECurrencySymbol
    Enum ECurrencySymbol
        USD
        EUR
        JPY
        GBP
        CHF
        CAD
        AUD
        NZD
        DKK
        SGD
        HKD
        MXN
        COP
    End Enum
    Public ReadOnly Property CurrencyString() As String
        Get
            Return Symbol.ToString
        End Get
    End Property
#End Region

#Region "Constructors"
    Sub New(ByVal name As String, ByVal CurrencySymbol As ECurrencySymbol)
        Me.Name = name
        Me.Symbol = CurrencySymbol
    End Sub
    Sub New(ByVal name As String, ByVal currencyString As String)
        Me.Name = name
        Me.Symbol = GetCurrencySymbolFromCurrencyString(currencyString)
    End Sub
#End Region

#Region "Shared Functions"

    Shared Function IsValidCurrencyString(ByVal currencyString As String) As Boolean
        Try
            Dim CSymbol As ECurrencySymbol = CType([Enum].Parse(GetType(ECurrencySymbol), currencyString.ToUpper), ECurrencySymbol)
            Return True ' si lo anterior no falla, es bien
        Catch ex As Exception
            Return False ' si falla es incorrecto
        End Try
    End Function
    Shared Function GetCurrencyFromString(ByVal currencyString As String, ByVal CurrencyDictionary As Dictionary(Of Currency.ECurrencySymbol, Currency)) As Currency
        For Each c As Currency In CurrencyDictionary.Values
            If c.Symbol.ToString.ToUpper = currencyString Then
                Return c
            End If
        Next
        Return Nothing
    End Function
    Shared Function GetCurrencySymbolFromCurrencyString(ByVal currencyString As String) As ECurrencySymbol
        Try
            Return CType([Enum].Parse(GetType(ECurrencySymbol), currencyString.ToUpper), ECurrencySymbol)
        Catch ex As Exception
            Throw New Exception("No se pudo hacer coincidir " & currencyString & " con alguno de las currencies existentes")
        End Try
    End Function
#End Region

End Class